package com.xypower.io;

import java.io.*;

/**
 * 输出文件.txt文本内容
 * 从硬盘获取到内存--读取
 */
public class ioTest2 {
    public static void main(String[] args) throws IOException {
        //文件位置
        File files = new File("E:\\workspace\\demo.txt");
        //文件输入流，节点流
        FileInputStream inputFileStream = new FileInputStream(files);
        //包装流,转换为字符流
        InputStreamReader inputStreamReader = new InputStreamReader(inputFileStream);
        //缓冲流
        BufferedReader bufferedReader = new BufferedReader(inputStreamReader);


        String line = null;
        int lineNum = 0;
        while ((line = bufferedReader.readLine()) != null){
            System.out.println(line);
            lineNum++;
        }
        System.out.println(lineNum);
        bufferedReader.close();
        inputStreamReader.close();
        inputFileStream.close();
    }
}
